<template>
  <div>
    <el-form :inline="true" :model="user" class="demo-form-inline">
      <el-form-item label="姓名">
        <el-input v-model="user.name" placeholder="姓名"></el-input>
      </el-form-item>
      <el-form-item label="公司">
        <el-input v-model="user.firm" placeholder="公司"></el-input>
      </el-form-item>
      <el-form-item label="电话">
        <el-input v-model="user.phone" placeholder="手机号精确查询"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="list">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table
        :data="tableData"
        border
        style="width: 100%">
      <el-table-column
          fixed
          prop="id"
          label="id"
          width="150">
      </el-table-column>
      <el-table-column
          prop="name"
          label="姓名"
          width="120">
      </el-table-column>
      <el-table-column
          prop="password"
          label="密码"
          width="120">
      </el-table-column>
      <el-table-column
          prop="phone"
          label="电话"
          width="120">
      </el-table-column>
      <el-table-column
          prop="firm"
          label="公司"
          width="300">
      </el-table-column>
      <el-table-column
          fixed="right"
          label="操作"
          width="100">
        <template slot-scope="scope">
          <el-button @click="del(scope.row.id)" type="text" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  name: "UserView",
  data() {
    return {
      user:{},
      pageNum:1,
      tableData:[],
    }
  }, methods: {
    list() {
      this.axios.post("http://localhost:9999/user/list?pageNum="+this.pageNum,this.user).then(res=>{
        this.tableData=res.data.data.list;
      })
    },del(id) {
      this.axios.post("http://localhost:9999/user/del?id="+id).then(res=>{
        if(res.data.code==200){
          this.$message.success(res.data.msg);
          this.list()
        }else{
          this.$message.error(res.data.msg);
        }
      })
    }
  }, created() {
      this.list();
  }
}
</script>

<style scoped>

</style>
